package com.nf.service;

import com.nf.dao.CarMapper;
import com.nf.entity.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

@Service("carService")
public class CarServiceImpl implements CarService {

    @Autowired
    private CarMapper carMapper;

    @Override
    @Transactional
    public List<Car> getAllCars() {
        return carMapper.getAllCar();
    }

    @Override
    @Transactional
    public boolean insertCar() {
        System.out.println("2.service调用dao插入");
        Car car1 = new Car();
        car1.setName("驰奔1");

        Car car2 = new Car();
        car2.setName("驰奔2驰奔驰奔驰奔驰奔驰奔驰奔驰奔驰奔2驰奔驰奔驰奔驰奔驰奔驰奔驰奔");

        carMapper.insertCar(car1);
        carMapper.insertCar(car2);

        return true;
    }
}
